<?php
$this->headTitle('Phân quyền','append');
?>
<div class="dashboard-menu dashboard-admin">
    <span class="back">&nbsp;</span>
    <a href="/admin/role"><h1>Phân quyền</h1></a>
    <span class="text"><?php echo $this->roleCheck['roleName'];?></span>
</div>
<div class="row placeholders">
    <div class="col-md-12">
        <div class="widget-big">
            <div class="search-result text-left">
                <?php
                    if(isset($this->mess)){
                        if($this->flag == 'success')
                            echo '<div class="bg-success">',$this->mess,'</div>';
                        elseif($this->flag == 'alert')
                            echo '<div class="bg-warning">',$this->mess,'</div>';
                        else
                            echo '<div class="bg-danger">',$this->mess,'</div>';
                    }
                ?>
                <form id="form" class="form-option" method="post" action="" enctype="multipart/form-data" name="form">
                    <dl class="zend_form">
                        <dt><label>Tên quyền</label></dt>
                        <dd><input type="text" id="roleName" name="roleName" value="<?php echo $this->roleCheck['roleName'];?>"/></dd>
                       
                        <dt><label>Chức năng admin</label></dt>
                        <dd>
                            <div class="option-wrapper">
                                <div class="fieldset">
                                    <div class="legend"><input type="checkbox" id="check_all_resource_admin"/><label>Chọn hết</label></div>
                                    <div class="fieldset-content">
                                    <ul>
                                    <?php 
                                        $resourceList = $this->roleCheck['resourceId'];
                                        $resourceList = json_decode($resourceList);
                                        foreach($this->resourceList as $resource){
                                            if($resource['moduleName'] == 'admin'){
                                                if(isset($resourceList) && is_array($resourceList) && in_array($resource['resourceId'],$resourceList))
                                                    echo "<li><input type='checkbox' class='resourceIdAdmin' name='resourceId[]' value='{$resource['resourceId']}' checked='checked'><label>{$resource['resourceName']}</label></li>";
                                                else
                                                    echo "<li><input type='checkbox' class='resourceIdAdmin' name='resourceId[]' value='{$resource['resourceId']}'><label>{$resource['resourceName']}</label></li>";
                                            }
                                        }
                                    ?>
                                    <div class="clearfix"></div>
                                    </ul>
                                    </div>
                                </div>
                            </div>
                        </dd>
                        <dt><label>Chức năng default</label></dt>
                        <dd>
                            <div class="option-wrapper">
                                <div class="fieldset">
                                    <div class="legend"><input type="checkbox" id="check_all_resource_default"/><label>Chọn hết</label></div>
                                    <div class="fieldset-content">
                                    <ul>
                                    <?php 
                                        $resourceList = $this->roleCheck['resourceId'];
                                        $resourceList = json_decode($resourceList);
                                        foreach($this->resourceList as $resource){
                                            if($resource['moduleName'] == 'default'){
                                                if(isset($resourceList) && is_array($resourceList) && in_array($resource['resourceId'],$resourceList))
                                                    echo "<li><input type='checkbox' class='resourceIdDefault' name='resourceId[]' value='{$resource['resourceId']}' checked='checked'><label>{$resource['resourceName']}</label></li>";
                                                else
                                                    echo "<li><input type='checkbox' class='resourceIdDefault' name='resourceId[]' value='{$resource['resourceId']}'><label>{$resource['resourceName']}</label></li>";
                                            }
                                        }
                                    ?>
                                    <div class="clearfix"></div>
                                    </ul>
                                    </div>
                                </div>
                            </div>
                        </dd>
                       
                        <dd id="submit-element">
                            <input value="Lưu thay đổi" class="button" type="submit" />
                            <input value="Reset" class="button" type="reset"/>
                        </dd>
                    </dl>
                </form>
            </div>
        </div>
    </div>
</div>